document.addEventListener('DOMContentLoaded', function () {
    const offcanvas = document.getElementById('offcanvasExample');

    // 监听鼠标移动事件
    document.addEventListener('mousemove', function (e) {
        if (e.clientX < 50) { // 假设屏幕边缘是50px以内
            // 显示侧边栏
            offcanvas.classList.add('show');
            offcanvas.classList.remove('hiding');
        } else {
            // 开始隐藏动画
            offcanvas.classList.add('hiding');
            offcanvas.classList.remove('show');
            offcanvas.addEventListener('transitionend', function handler() {
                if (offcanvas.classList.contains('hiding')) {
                    offcanvas.classList.remove('show', 'hiding');
                }
                offcanvas.removeEventListener('transitionend', handler);
            });
        }
    });
});